package com.main;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.MathUtils;
import com.main.StaticTileData.Type;

public class Tile {
	public Type type;
	public int value;
	public Tile(Type t) {
		type = t;
		if (t == Type.Grass) {
			if (MathUtils.random(1000) <= 15) {
				int flowerType = MathUtils.random(1);
				if (flowerType == 0) {
					type = Type.Grass_Blue_Flower_2;
				} else {
					type = Type.Grass_Red_Flower_3;
				}
			} else if (MathUtils.random(1000) < 8) {
				type = Type.BlueBerry;
			} else if (MathUtils.random(1000) < 5) {
				type = Type.Grass_Stone;
			}
		}
	}
	public void setType(Type t) {
		type = t;
	}
	public void render(int x, int y, SpriteBatch sb) {
		if (type == StaticTileData.Type.Water) {
			StaticTextures_Water.images[value].setPosition(x, y);
			StaticTextures_Water.images[value].draw(sb);
		} else {
			StaticTileData.sprites.get(type).setPosition(x,y);
			StaticTileData.sprites.get(type).draw(sb);
		}
	}
}
